DOSLFNBK v 1.0 - Backs up/restores Win95 long filenames in DOS Copyright (c) 1995 D.J. Murdoch. 0. Contents of this file 1. Syntax 2. Description 3. Details 4. Memory Limitations 5. Safety 6. Recovery from Total Disk Failure 7. License 8. Release History 9. Acknowledgments 1. Syntax: DOSLFNBK directory [options] will back up all the long filename records in the named directory and subdirectories of it to a file called BACKUP.LFN. Options: /f filename Back up to this file instead (default .LFN extension) /force Force DOSLFNBK to go ahead without asking questions, even when it may be unsafe /nr No recursive: don't do subdirectories /nt Don't restore times from LFN backup /p Prompt before each filename restore (ignored during saves) /r Restore from existing backup /v Give running status report /d filename Write a detailed debugging log to filename Examples: For recovery from a total disk failure, see below. To back up every long filename on the disk into BACKUP.LFN: doslfnbk c:\ To restore just the Windows directory and subdirectories: lock c: doslfnbk c:\windows /r unlock c: To restore just the root directory, but no subdirectories: lock c: doslfnbk c:\ /r /nr unlock c: The following is not allowed; you need a full path: doslfnbk . <---- Error! To restore the "Program Files" directory name and its subdirectories, you need two runs: lock c: doslfnbk c:\PROGRA~1 /r doslfnbk c:\ /r /p /nr unlock c: On the second run, you'll be prompted for each name to restore; just say yes when you see "Program Files". 2. Description: Microsoft's Windows 95 introduces long filenames (LFNs), and they are mostly compatible with old software. However, there are some problems. Old backup programs don't recognize LFNs, so they don't get properly backed up. Worse, the Win95 backup program doesn't support a lot of common backup hardware (e.g. Colorado Memory Systems tape drives using accelerator cards) and won't run in DOS mode, so recovery from a catastrophic disk failure can be really difficult. To address this problem, Microsoft put a program called LFNBK on the Win95 CD ROM to back up your LFNs. However, it's very inconvenient to use. It requires changes to your Control Panel settings before and after use, and it works by stripping all the LFNs off your disk --- so you need to restore them again after you've done your backup to tape. It will only run after Win95 has booted, so again you've got big problems after a catastrophic disk failure. If you've got a program that is completely incompatible with LFNs then you might want to use LFNBK, but for routine system backups it's too much of a pain. I wrote DOSLFNBK to address these problems. It runs in any version of DOS that can see your disk, and can both backup and restore your files there. During backup, it makes no changes to the names, so you can routinely run it just before a tape backup and not have to undo the damage afterwards. It also allows partial backups and partial restores; I'm pretty sure LFNBK is an all-or-nothing affair. The downside of DOSLFNBK is that it has to work on the disk below the file system level. This means that if other programs are running simultaneously, it can get confused, and may cause errors in the backup or even errors on the disk itself. I recommend running it only in a single-tasking DOS session, unless you're quite sure no other program is writing to the disk. 3. Details: When doing a backup, DOSLFNBK reads the directories on the disk and writes copies of all of the LFN records to the BACKUP.LFN file (or whatever file you specify with /f). If you use the /nr option, it will work only on the specified directory; otherwise, it saves those entries as well as everything in any subdirectory below it. You'll get a warning if you run it in Windows mode, since other programs might change the directories while DOSLFNBK is running and cause it to store and/or restore garbage. The /force option tells DOSLFNBK to go ahead without stopping for this warning, or several others (e.g. overwriting the backup file). Use it in a batch file only when you're sure you always want it to go ahead. You *must* give the drive letter and a full path to the directory; relative directory specifications are not supported. Note that the directory name itself won't be backed up or restored; only the files and subdirectories within it. There is no way to specify a subset of the files; you have to use the /p prompting option if you want this. The original drive letter is not stored in BACKUP.LFN, so you can use DOSLFNBK to save the long filenames on one drive, use a DOS utility to move them to another drive, and then restore the filenames there. During a restore, you should use the DOS command LOCK to give DOSLFNBK access to the disk at a low level. I can't find documentation for LOCK anywhere, but perhaps it would also make it safe to run DOSLFNBK in a multitasking environment. DOSLFNBK will normally not overwrite an existing LFN with a different one; you should rename the file to its 8.3 alias before running if you want to restore an old name, or run with the /p option for individual prompting. Normally, DOSLFNBK will restore the backed up date information, since older DOS versions and DOS utilities probably don't save this properly. You can override this behaviour by using the /nt switch. If during a restore, DOSLFNBK detects that the file size has changed, you'll be prompted as to whether you want to restore the LFN or not. If you choose to restore it, the date information will *not* be restored, as it is probably incorrect. During a restore, the file attributes of the file on the disk will be kept. To show you the progress of a run, DOSLFNBK prints a dot for about every 10 directories examined or (in /v mode) prints the directory and file names. If it stops printing for more than a few seconds, something is probably wrong. Try running again with the /d debug log option, and if it stops again, please email me (dmurdoch@mast.queensu.ca) a copy of your log, along with a description of your system. I'm very interested in making DOSLFNBK as bug-free as possible. When a run is successful, DOSLFNBK exits with ERRORLEVEL 0. When something goes wrong, it prints an error message and exits with a higher errorlevel. The currently defined error levels are: 99 = Syntax error 98 = Error initializing disk 97 = Error reading disk 96 = Error writing disk 95 = Error in directory on disk 94 = Error setting up directory 93 = Error opening backup 92 = Error reading backup 91 = Error writing backup 90 = Error closing backup 89 = Memory error 88 = Multitasker running 87 = Backup file exists 86 = Debug log problem 4. Memory Limitations: When running, DOSLFNBK keeps copies of several directories in memory at once. It is written as a real mode DOS program and keeps all of this data in the low 640K of memory. This means that in a typical DOS session with 500K of memory available, DOSLFNBK will run out of memory when about 15,000 directory entries are in memory. On a restore, up to 3 copies of each directory entry may be in memory at once, limiting DOSLFNBK to disks with fewer than 5000 directory entries in any branch of the directory tree. (The total number of files on the disk doesn't matter; what matters is the number of entries in a directory, its parent, grandparent etc., back to the root.) I think disks approaching this limit are very unusual. However, it *is* possible to have such a disk, and here's how to find out if you do: Run your backup with the /V verbose option. At the end, it will print a message something like Used 255K; restore will require about 264K in DOS session. If the amount of memory estimated for the restore is more than you have available (as reported by the DOS MEM command), you might have problems. You might not; the number reported is usually an overestimate. If it ever turns out that you do run out of memory during a restore, you can still restore the LFNs by breaking up the restore operation into several steps, restoring different parts of your subdirectory tree separately. In the worst case (more than 5000 entries in a single subdirectory), you may have to temporarily move files out of the directory and restore the LFNs a few thousand (!!) at a time. 5. Safety: DOSLFNBK works with your disk at a level below the file system, so if things go wrong during an LFN restore, it's conceivable that you could lose whole files or directories. I've tried to make it as safe as I can, but you should follow some simple precautions: - If you aren't sure of the integrity of your file system, run Scandisk before DOSLFNBK and get it to fix any errors. In particular, if you've run other low level software (e.g. a defragger or a directory sorter) that may have messed up the LFNs, run Scandisk first. - If you choose to run in Windows despite the warning about the multitasker, then definitely don't make changes to files in the directories where DOSLFNBK is currently restoring LFNs. You're *very* likely to lose your new work. - Don't turn off or reboot your PC in the middle of a DOSLFNBK run. If there's a power failure or (horrors!) a bug in DOSLFNBK forces you to reboot, then Scandisk should be able to repair much of the damage. You may lose some filenames, but Scandisk should be able to recover the files themselves. - If you hit Ctrl-Break or Ctrl-C during a DOSLFNBK restore, it shouldn't do any damage other than giving you only a partial restore of your LFNs --- but this is *not* a well-tested feature, and there may be conditions under which you'll suffer worse damage. Again, Scandisk should be able to repair most of it. - DOSLFNBK was written for version 4.00.950 of Windows 95 (the August 1995 release). It hasn't been tested on the earlier beta test versions or on any later releases. If the VFAT file structure isn't what DOSLFNBK is written for, it could do some real damage. - This is the first release of DOSLFNBK to the public. There may still be special conditions on your system that it doesn't handle. If you can, try it out when you've got a good second backup to make sure it works. If it doesn't, *please* send me details, and I'll attempt to fix it. 6. Recovery from total disk failure: If your boot disk fails, or you decide to repartition it, then you may need to do a full restore from a backup tape. Unfortunately, the Win95 backup program provides *no way* to do this without re-installing Win95 from the original disks or CD ROM. From reports I've heard, the same is true of the just-released Win95 version of Colorado Memory System's backup program and some other commercial backup programs. However, if you have a reliable DOS-based backup program, DOSLFNBK will let you do a complete restore from a backup. I've only had to do this once, so these instructions aren't guaranteed to cover everything for every system, but they worked on mine. ADVANCE PREPARATIONS: Before your disk fails (i.e. right now! :-), you need to prepare the following: 1. A Win95 startup disk. If you didn't create one when you installed Win95, start the Add/Remove Programs option in Control Panel, and click the Startup Disk tab. Then click the Create Disk button, and follow the instructions on-screen. 2. A copy of your DOS-based backup/restore program on a floppy disk. It may require EMS memory; if so, you should put HIMEM.SYS and EMM386.EXE on your startup disk, and load them via CONFIG.SYS. 3. If you use Drivespace disk compression, then you should also make sure that the MINI.CAB file from the installation disks or the CD ROM is in your Windows directory. 4. A full backup of your disk(s). Just before creating this, run DOSLFNBK to save all of your long filenames. You'll need to create one backup file for each disk. It's fine to leave this on the hard disk so that it ends up on the backup; you don't need to have it on floppy disk. WHEN YOUR DISK FAILS: Depending on the reason for your disk failure, you may be able to skip some of the early steps here. Read them over, and figure out where to start. If you have to, you can start again, so the only thing you lose by starting too far down is time. 1. Make any necessary repairs to your hardware. 2. Boot from your Startup disk, and use FDISK to partition your disk. Use "FORMAT c: /s" to reformat the disk and transfer the system files to it. 3. (Optional) Transfer your tape backup software to your hard disk. 4. If you're not planning to use Drivespace, you can skip down to step 8. 5. If you want to compress your drive, you need to restore enough of Win95 to run Drivespace. Don't restore the whole disk; you might not have room for it. For most people, restoring the files in the root directory and the files in the Windows directory should be enough. If you have any essential drivers in other directories, you'll need to restore them too. Finally, you should restore DOSLFNBK and the data file(s) containing the backed up long filenames. IMPORTANT: You should not overwrite IO.SYS, but you *should* overwrite MSDOS.SYS. It is a hidden read-only file in your root directory. A good way is to erase MSDOS.SYS before starting the restore (use ATTRIB from the Startup disk to remove the System, Hidden, Read-only attributes), and then telling your restore program not to overwrite existing files. Restore all those files now. 6. Restore the long filenames by running LOCK C: DOSLFNBK c:\ /R /V /F backupfilename 7. Remove the Startup disk, and reboot your system. You may get some errors about missing drivers (e.g. no sound card drivers), but things should basically work. Run DriveSpace to compress your drives the way you want. 8. Reboot your system in DOS mode or from the Startup disk. 9. Restore all rest of the files on all of your disks from the backup now. See the "IMPORTANT" note in step 5 about MSDOS.SYS and IO.SYS. 10. Restore all the rest of your long filenames by running LOCK C: DOSLFNBK c:\ /R /V /F backupfilename and if you've also got a D: partition, LOCK D: DOSLFNBK d:\ /R /V /F backupfilename You may get messages about some long filenames already existing from your first restore; don't worry about those. 11. Some restore programs set the archive bit on all restored files; you might want to turn it off (since you've still got those files backed up) at this point. Reboot your system, and things should be back as they were when you did your backup! 7. License: DOSLFNBK is *not* public domain software, but you may use it at no charge. You may distribute unmodified copies of the complete DOSLFNBK package, provided your total charge is no more than $1. The total cost of a compilation (e.g. a CD ROM) including DOSLFNBK must be no more than $1 per package in the compilation. DOSLFNBK was written in Borland Pascal 7.01, using the excellent Object Professional library from TurboPower Software. You can obtain the source code (including an object-oriented low-level disk access unit and a huge memory support unit, but not Opro) by sending a cheque or money order for $50 (in Canadian or US dollars, or the UKP equivalent of $50US) to: Duncan Murdoch 337 Willingdon Ave. Kingston, Ontario, Canada. K7L 4J3 You can also order source code from the Public (software) Library (PsL) using MC, Visa, AmEx, or Discover card: - by calling 800-242-4775 (US only) - by calling 713-524-6394 - by faxing your order to 713-524-6398 - by sending your order by Compuserve to 71355,470. - by sending your order by Internet to 71355.470@compuserve.com PsL only accepts payment in US dollars. Please give PsL your name exactly as it appears on the card, and tell them your card's expiry date. The PsL numbers are for ordering only. I *cannot* be reached at the PsL numbers. To contact me for information about dealer pricing, volume discounts, site licensing, the status of shipment of the product, the latest version number or for technical information write to me at the address above or at one of the email addresses below. I'd especially like to hear bug reports and suggestions for improvements. Fidonet: DJ Murdoch at 1:249/99.5 Internet: dmurdoch@mast.queensu.ca Compuserve: 71631,122 8. Release history: 0.0 - first beta test version 0.1 - kept file attributes of existing file during restore. 0.2 - made messages more informative; fixed bug in handling erased file entries; added check of overwrite of backup file; changed default name of backup file to BACKUP.LFN and made LFN the default backup extension; added /P option. 0.3 - fixed memory leak that caused run-time error 203 on large restore 0.4 - added check for successful write of backup file, added /force option. 0.5 - added report of memory use, /d option, many debugging messages 0.6 - cleaned up messages and debug log, removed disk size restriction, added progress dots for non-verbose runs. 9. Acknowledgments DOSLFNBK was written based on the information in Robert Hummel's article on Win95 long filenames in the June/July 1995 issue of PC Techniques Magazine. Thanks are due to the beta testers, who suggested many improvements, and several of whom were put to considerable inconvenience by early versions that messed up their disks.